package cn.doitedu.day04

import org.apache.spark.{SparkConf, SparkContext}

object T08_TopDemo {

  def main(args: Array[String]): Unit = {

    //1.创建SparkConf
    val conf = new SparkConf().setAppName("WordCount")
      .setMaster("local[4]") //如果提交到集群中运行，setMaster必须注释掉

    //2.创建SparkContext
    val sc = new SparkContext(conf)

    val rdd1 = sc.parallelize(List(
      5, 7, 6, 4,
      9, 6, 1, 7,
      8, 2, 8, 5,
      4, 3, 10, 9
    ), 4)


    val res = rdd1.takeOrdered(3)(Ordering[Int].reverse)

    println(res.toBuffer)

  }

}
